package com.bckj.fastboot.paid.biz.infrastructure.sdk;

import com.bckj.fastboot.paid.api.constant.PayWayConstants;
import com.bckj.fastboot.paid.api.constant.RefundWayConstants;
import com.bckj.fastboot.paid.biz.infrastructure.sdk.wechatpay.WechatPayConfigProvider;
import com.bckj.fastboot.paid.biz.infrastructure.sdk.wechatpay.WechatRefundServiceWrapper;
import com.bckj.fastboot.paid.biz.infrastructure.sdk.wechatpay.jsapi.WechatpayJsapiPayServiceWrapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
public class PayServiceWrapperFactory {
    public PayServiceWrapper getPayServiceWrapper(String appId, String payWay) {
        PayServiceWrapper serviceWrapper = null;
        switch (payWay) {
            case PayWayConstants.WECHAT_PAY_JSAPI -> {
                WechatpayJsapiPayServiceWrapper wrapper = new WechatpayJsapiPayServiceWrapper(appId);
                wrapper.setPayConfigWrapper(WechatPayConfigProvider.get(appId));
                serviceWrapper = wrapper;
            }
            case RefundWayConstants.WECHAT_REFUND -> {
                WechatRefundServiceWrapper wrapper = new WechatRefundServiceWrapper(appId);
                wrapper.setPayConfigWrapper(WechatPayConfigProvider.get(appId));
                serviceWrapper = wrapper;
            }
        }
        return serviceWrapper;
    }


}
